package org.springblade.modules.comment.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.core.tool.constant.RoleConstant;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.classes.excel.QyClassesLessonsExcel;
import org.springblade.modules.classes.pojo.entity.QyClassesEntity;
import org.springblade.modules.classes.pojo.entity.QyClassesLessonsEntity;
import org.springblade.modules.classes.pojo.entity.QyClassesRoomEntity;
import org.springblade.modules.classes.pojo.vo.QyClassesLessonsVO;
import org.springblade.modules.classes.service.IQyClassesLessonsService;
import org.springblade.modules.classes.service.IQyClassesRoomService;
import org.springblade.modules.classes.service.IQyClassesService;
import org.springblade.modules.classes.wrapper.QyClassesLessonsWrapper;
import org.springblade.modules.system.pojo.entity.Role;
import org.springblade.modules.system.pojo.entity.User;
import org.springblade.modules.system.service.IRoleService;
import org.springblade.modules.system.service.IUserService;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


/**
 * 课表 控制器
 *
 * @author BladeX
 * @since 2024-06-23
 */
@RestController
@AllArgsConstructor
@RequestMapping("blade-qyClasses/qyComment")
@Tag(name = "课表", description = "课表接口")
public class qyCommentController extends BladeController {

	private final IQyClassesService qyClassesService;

	private final IQyClassesRoomService qyClassesRoomService;

	private final IUserService userService;

	private final IRoleService roleService;

	/**
	 * 教室列表
	 */
	@GetMapping("/classes")
	@ApiOperationSupport(order = 2)
	@Operation(summary = "list", description  = " ")
	public R<List<QyClassesEntity>> classes() {
		List<QyClassesEntity> list = qyClassesService.list(new QueryWrapper<QyClassesEntity>().lambda().select(QyClassesEntity::getName, QyClassesEntity::getId).ne(QyClassesEntity::getStatus, -1));
		return R.data(list);
	}
	/**
	 * 教室列表
	 */
	@GetMapping("/classes_rooms")
	@ApiOperationSupport(order = 2)
	@Operation(summary = "list", description  = " ")
	public R<List<QyClassesRoomEntity>> classes_rooms() {

		List<QyClassesRoomEntity> list = qyClassesRoomService.list(new QueryWrapper<QyClassesRoomEntity>().lambda().select(QyClassesRoomEntity::getName, QyClassesRoomEntity::getId).ne(QyClassesRoomEntity::getStatus, -1));
		return R.data(list);
	}

	/**
	 * 老师列表
	 */
	@GetMapping("/teaches")
	@ApiOperationSupport(order = 2)
	@Operation(summary = "list", description  = " ")
	public R<List<User>> teaches() {
		Role temp = roleService.getOne(new QueryWrapper<Role>().lambda().eq(Role::getRoleName, "老师").eq(Role::getTenantId, AuthUtil.getTenantId()));
		if(temp != null){
			List<User> list = userService.list(new QueryWrapper<User>().lambda().select(User::getRealName,User::getId).eq(User::getRoleId,temp.getId()));
			return R.data(list);
		}else{
			return R.data(new ArrayList<>());
		}
	}

}
